<?php

namespace App\Models\Factory;


use App\Models\AbsModelFactory;
use App\Models\Orm\UserStatus;


/**
 * 用户状态工厂
 * Class UserFactory
 * @package App\Models\Factory
 */
class UserStatusFactory extends AbsModelFactory
{




    //修改个人图片状态信息
    public static  function updateImage($userId,$data)
    {
        $userIdentity['user_id'] = $userId;
        $userIdentity['image_status'] = $data;
        $resultOccupation = UserStatus::updateOrCreate(['user_id'=>$userId],$userIdentity);
        return $resultOccupation ? true :false;

    }

    //用户所有身份证照片完成状态
    public static  function updateIdCardImage($userId,$data)
    {
        $userIdentity['user_id'] = $userId;
        $userIdentity['id_card_total'] = $data;
        $resultOccupation = UserStatus::updateOrCreate(['user_id'=>$userId],$userIdentity);
        return $resultOccupation ? true :false;
    }




    //修改用户图片总状态
    public static function updateImageStatus($userId,$data)
    {
        $userIdentity['user_id'] = $userId;
        $userIdentity['image_status'] = $data;
        $resultOccupation = UserStatus::updateOrCreate(['user_id'=>$userId],$userIdentity);
        return $resultOccupation ? true :false;
    }

    //修改用户身份照片状态
//    public static function updateImage($userId,$data)
//    {
//        $userIdentity['user_id'] = $userId;
//        $userIdentity['image_status'] = $data;
//        $resultOccupation = UserStatus::updateOrCreate(['user_id'=>$userId],$userIdentity);
//        return $resultOccupation ? true :false;
//    }

    public static  function updateUserStatus($userId,$data,$type)
    {
        switch ($type)
        {
            case 1 :
            $user['user_profile_status'] = $data;
             break;
            case 2 :
            $user['bank_status'] = $data;
            break;
            case 3 :
                $user['occupation_status'] = $data;
            break;
            case 4 :
                $user['basic_status'] = $data;
            break;
            case 5 :
                $user['ali_status'] = $data;
            break;
            case 6 :
                $user['tao_status'] = $data;
            break;
            case 7 :
                $user['cap_status'] = $data;
            break;
            case 8 :
                $user['id_card_total'] = $data;
            break;
            case 9 :
                $user['user_profile_status'] = $data;
            break;
            case 10 :
                $user['id_card_face'] = $data;
            break;
            case 11 :
                $user['id_card_side'] = $data;
                break;
            case 12 :
                $user['id_card_hand'] = $data;
                break;
            case 13 :
                $user['debit_card_status'] = $data;
                break;
            case 14 :
                $user['credit_card_status'] = $data;
                break;
            case 15 :
                $user['license_status'] = $data;
                break;
            case 16 :
            $user['work_card_status'] = $data;
            break;
            case 16 :
                $user['image_status'] = $data;
            break;
            default:
                break;
        }
        //用户的id
        $user['user_id'] = $userId;
        $result = UserStatus::updateOrCreate(['user_id'=>$userId],$user);
        return $result ? true : false;
    }

//查询用户状态表
    public static function getUser($user_id)
    {
        $result = UserStatus::where('user_id',$user_id)->first();

        return $result ? $result : '';
    }

    //初始化插入一条数据
    public static function initIntegral($user_id)
    {
        $data['user_id'] = $user_id;
        $result =  UserStatus::firstOrCreate($data);
        return $result ? true : false;
    }

}
